//
//  ReviewOfTheOrderTableViewCell.m
//  OrderAssistant
//
//  Created by chendong on 2020/10/28.
//  Copyright © 2020 chendong. All rights reserved.
//

#import "ReviewOfTheOrderTableViewCell.h"
@interface ReviewOfTheOrderTableViewCell()
@property(nonatomic,strong)UILabel *ddbhL;
@property(nonatomic,strong)UILabel *xdrqL;
@property(nonatomic,strong)UILabel *zdrL;
@property(nonatomic,strong)UILabel *xdbmL;
@property(nonatomic,strong)UILabel *ssxdbmL;
@end
@implementation ReviewOfTheOrderTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = RGBCOLOR(248, 248, 248);
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        UIView *bgV = [[UIView alloc]initWithFrame:CGRectMake(10, 5, SCREENWIDTH-20, 125)];
        bgV.backgroundColor = [UIColor whiteColor];
        bgV.layer.cornerRadius = 5;
        bgV.clipsToBounds = YES;
        [self.contentView addSubview:bgV];
        self.bgV = bgV;
        
        UILabel *ddbhL = [[UILabel alloc]initWithFrame:CGRectMake(2, 0, (bgV.frame.size.width-4)/3.0*2, 25)];
        ddbhL.text = @"订单编号:202002002";
        ddbhL.textColor = [UIColor blackColor];
        ddbhL.font = [UIFont systemFontOfSize:14];
        [bgV addSubview:ddbhL];
        self.ddbhL = ddbhL;
        
        UILabel *xdrqL = [[UILabel alloc]initWithFrame:CGRectMake(ddbhL.frame.origin.x, CGRectGetMaxY(ddbhL.frame), ddbhL.frame.size.width, 25)];
        xdrqL.text = @"下单日期:202002002";
        xdrqL.textColor = [UIColor blackColor];
        xdrqL.font = [UIFont systemFontOfSize:14];
        [bgV addSubview:xdrqL];
        self.xdrqL = xdrqL;
        
        UILabel *xdbmL = [[UILabel alloc]initWithFrame:CGRectMake(ddbhL.frame.origin.x, CGRectGetMaxY(xdrqL.frame), ddbhL.frame.size.width, 25)];
        xdbmL.text = @"下单部门:五一路凉菜库";
        xdbmL.textColor = [UIColor blackColor];
        xdbmL.font = [UIFont systemFontOfSize:14];
        [bgV addSubview:xdbmL];
        self.xdbmL = xdbmL;
        
        UILabel *remm = [[UILabel alloc]initWithFrame:CGRectMake(ddbhL.frame.origin.x, CGRectGetMaxY(xdbmL.frame), 45, 25)];
        remm.text = @"备注：";
        remm.textColor = RGBCOLOR(150, 150, 150);
        remm.font = [UIFont systemFontOfSize:14];
        [bgV addSubview:remm];
        
        UILabel *remarkL = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(remm.frame), CGRectGetMaxY(xdbmL.frame)+5, bgV.frame.size.width-CGRectGetMaxX(remm.frame)-10, 20)];
        remarkL.text = @"备注:五一路凉菜库";
//        remarkL.backgroundColor = [UIColor redColor];
        remarkL.textColor = [UIColor blackColor];
        remarkL.font = [UIFont systemFontOfSize:14];
//        [remarkL sizeToFit];
        remarkL.numberOfLines = 0;
        [bgV addSubview:remarkL];
        self.remarkL = remarkL;
        
        UILabel *zdrL = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(ddbhL.frame), ddbhL.frame.origin.y, ddbhL.frame.size.width/2.0, 25)];
        zdrL.text = @"制单人：张无忌";
        zdrL.textColor = [UIColor blackColor];
        zdrL.font = [UIFont systemFontOfSize:14];
        [bgV addSubview:zdrL];
        self.zdrL = zdrL;
        
        UILabel *ssxdbmL = [[UILabel alloc]initWithFrame:CGRectMake(zdrL.frame.origin.x, CGRectGetMaxY(zdrL.frame), zdrL.frame.size.width, 25)];
        ssxdbmL.text = @"订单状态：已上传";
        ssxdbmL.textColor = [UIColor blackColor];
        ssxdbmL.font = [UIFont systemFontOfSize:14];
        [bgV addSubview:ssxdbmL];
        self.ssxdbmL = ssxdbmL;
        
    }
    return self;
}
-(void)setDic:(ReviewOfTheOrderTableViewCellFrame *)dic{
    _dic = dic;
    NSMutableAttributedString * firstPart = [[NSMutableAttributedString alloc] initWithString:@"订单编号："];
        NSDictionary * firstAttributes = @{ NSFontAttributeName:[UIFont boldSystemFontOfSize:14],NSForegroundColorAttributeName:RGBCOLOR(150, 150, 150)};
        [firstPart setAttributes:firstAttributes range:NSMakeRange(0,4)];
        NSMutableAttributedString * secondPart = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",dic.dic[@"OrderID"]]];
        NSDictionary * secondAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor blackColor]};
        [secondPart setAttributes:secondAttributes range:NSMakeRange(0,secondPart.length)];
        [firstPart appendAttributedString:secondPart];
    self.ddbhL.attributedText = firstPart;

//    self.ddbhL.text = [NSString stringWithFormat:@"订单编号：%@",dic.dic[@"OrderID"]];
    
    NSMutableAttributedString * firstPart1 = [[NSMutableAttributedString alloc] initWithString:@"下单日期："];
        NSDictionary * firstAttributes1 = @{ NSFontAttributeName:[UIFont boldSystemFontOfSize:14],NSForegroundColorAttributeName:RGBCOLOR(150, 150, 150)};
        [firstPart1 setAttributes:firstAttributes1 range:NSMakeRange(0,5)];
        NSMutableAttributedString * secondPart1 = [[NSMutableAttributedString alloc] initWithString:[[NSString stringWithFormat:@"%@",dic.dic[@"OperateTime"]] stringByReplacingOccurrencesOfString:@"T"withString:@" "]];
        NSDictionary * secondAttributes1 = @{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor blackColor]};
        [secondPart1 setAttributes:secondAttributes1 range:NSMakeRange(0,secondPart1.length)];
        [firstPart1 appendAttributedString:secondPart1];
    self.xdrqL.attributedText = firstPart1;
//    self.xdrqL.text = [[NSString stringWithFormat:@"下单日期：%@",dic.dic[@"OperateTime"]]stringByReplacingOccurrencesOfString:@"T"withString:@" "];
    
    NSMutableAttributedString * firstPart2 = [[NSMutableAttributedString alloc] initWithString:@"制  单  人："];
        NSDictionary * firstAttributes2 = @{ NSFontAttributeName:[UIFont boldSystemFontOfSize:14],NSForegroundColorAttributeName:RGBCOLOR(150, 150, 150)};
        [firstPart2 setAttributes:firstAttributes2 range:NSMakeRange(0,firstPart2.length)];
        NSMutableAttributedString * secondPart2 = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",dic.dic[@"Operator"]]];
        NSDictionary * secondAttributes2 = @{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor blackColor]};
        [secondPart2 setAttributes:secondAttributes2 range:NSMakeRange(0,secondPart2.length)];
        [firstPart2 appendAttributedString:secondPart2];
    self.zdrL.attributedText = firstPart2;
//    self.zdrL.text = [NSString stringWithFormat:@"制  单  人：%@",dic.dic[@"Operator"]];
    
    NSMutableAttributedString * firstPart3 = [[NSMutableAttributedString alloc] initWithString:@"下单部门："];
        NSDictionary * firstAttributes3 = @{ NSFontAttributeName:[UIFont boldSystemFontOfSize:14],NSForegroundColorAttributeName:RGBCOLOR(150, 150, 150)};
        [firstPart3 setAttributes:firstAttributes3 range:NSMakeRange(0,5)];
        NSMutableAttributedString * secondPart3 = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",dic.dic[@"Warehouse"]]];
        NSDictionary * secondAttributes3 = @{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor blackColor]};
        [secondPart3 setAttributes:secondAttributes3 range:NSMakeRange(0,secondPart3.length)];
        [firstPart3 appendAttributedString:secondPart3];
    self.xdbmL.attributedText = firstPart3;
//    self.xdbmL.text = [NSString stringWithFormat:@"下单部门：%@",dic.dic[@"Warehouse"]];
    
    NSMutableAttributedString * firstPart4 = [[NSMutableAttributedString alloc] initWithString:@"订单状态："];
        NSDictionary * firstAttributes4 = @{ NSFontAttributeName:[UIFont boldSystemFontOfSize:14],NSForegroundColorAttributeName:RGBCOLOR(150, 150, 150)};
        [firstPart4 setAttributes:firstAttributes4 range:NSMakeRange(0,5)];
        NSMutableAttributedString * secondPart4 = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",dic.dic[@"UploadFlag"]]];
        NSDictionary * secondAttributes4 = @{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor blackColor]};
        [secondPart4 setAttributes:secondAttributes4 range:NSMakeRange(0,secondPart4.length)];
        [firstPart4 appendAttributedString:secondPart4];
    self.ssxdbmL.attributedText = firstPart4;
    
//    self.ssxdbmL.text = [NSString stringWithFormat:@"订单状态：%@",dic.dic[@"UploadFlag"]];
    NSMutableParagraphStyle*paragraphStyle = [[NSMutableParagraphStyle alloc]init];

    paragraphStyle.lineSpacing=0;//字体的行间距

    NSDictionary*attributes =@{

    NSFontAttributeName:[UIFont systemFontOfSize:14],

    NSParagraphStyleAttributeName:paragraphStyle,

    NSForegroundColorAttributeName:[UIColor blackColor]

    };

    NSMutableAttributedString *attributeText = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",dic.dic[@"OrderBZ"]] attributes:attributes];
    self.remarkL.attributedText = attributeText;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    CGRect re1 = self.remarkL.frame;
    re1.size.height = self.dic.remarkH;
    self.remarkL.frame = re1;
    CGRect re2 = self.bgV.frame;
    re2.size.height = self.dic.bgVH;
    self.bgV.frame = re2;
}


@end
